﻿#region Copyright

// /*
// SilverlightInEnterprise
// SilverlightInEnterprise.UnitTesting.TargetApplication
// ActiveScreensViewModel.cs
// 
// Author: Matt Van Horn
// Created 11/16/2011 2:52 PM
// Copyright: Silverlight in the Enterprise www.slinenterprise.com
// 
// Licensed under MS-PL http://www.opensource.org/licenses/MS-PL and while you 
// may use this in anyway you see fit and owe us nothing to do so, we wouldn't mind knowing that you got value out of the work we did (so we will do more) so 
// we ask that you leave a comment on www.slinenterprise.com or on the codeplex site slinenterprise.codeplex.com
// 
// */

#endregion

using System;
using System.Collections.ObjectModel;
using System.ComponentModel.Composition;
using SilverlightInEnterprise.Core.ViewModels;
using SilverlightInEnterprise.UnitTesting.TargetApplication.Events;

namespace SilverlightInEnterprise.UnitTesting.TargetApplication.ViewModels
{
    public class ActiveScreensViewModel : ViewModelBase
    {
        private readonly ObservableCollection<ScreenViewModelBase> leftScreens =
            new ObservableCollection<ScreenViewModelBase>();

        private readonly ObservableCollection<ScreenViewModelBase> rightScreens =
            new ObservableCollection<ScreenViewModelBase>();

        public ObservableCollection<ScreenViewModelBase> LeftScreens
        {
            get { return this.leftScreens; }
        }

        public ObservableCollection<ScreenViewModelBase> RightScreens
        {
            get { return this.rightScreens; }
        }

        private OpenScreenEvent openScreenEvent;
        private CloseScreenEvent closeScreenEvent;

        [ImportingConstructor]
        public ActiveScreensViewModel(CloseScreenEvent closeEvent, OpenScreenEvent openEvent)
        {
            closeEvent.Subscribe(OnScreenClose);
            openEvent.Subscribe(OnScreenOpen);
        }

        private void OnScreenOpen(ScreenViewModelBase screen)
        {
            if (screen.Location == ScreenLocation.Left)
            {
                this.leftScreens.Add(screen);
            }
            else
            {
                this.rightScreens.Add(screen);
            }
        }

        private void OnScreenClose(ScreenViewModelBase screen)
        {
            throw new NotImplementedException();
        }
    }
}